﻿using AnyCAD.Foundation;
using AnyCAD.WPF.ViewModel;
using Rapid.Sketch.Plugin.Model;
using System.ComponentModel;

namespace Rapid.Sketch.Plugin.ViewModel
{
    public class SectionBarViewModel : ElementViewModel
    {
        public SectionBarViewModel(ShapeElement model, Document doc, PropertyChangedEventHandler callback)
            :base(model, doc)
        {
            PropertyChanged += callback;
        }

        public double InnerRadius {
            get => GetProperty(nameof(SectionBarModel.InnerRadius), SectionBarModel.InnerRadius);
            set => SetProperty(nameof(InnerRadius), value, () => { return value > 0; }, nameof(OutterRadius));
        }
        public double Thickness { 
            get => GetProperty(nameof(SectionBarModel.Thickness), SectionBarModel.Thickness);
            set => SetProperty(nameof(SectionBarModel.Thickness), value, () => { return value > 0; }, nameof(OutterRadius));
        }

        public double OutterRadius
        {
            get => InnerRadius + Thickness;
        }
        public double Length { 
            get => GetProperty(nameof(SectionBarModel.Length), SectionBarModel.Length);
            set => SetProperty(nameof(SectionBarModel.Length), value, () => { return value > 0; });
        }
    }
}
